/**
 * Created by gongxun on 17/3/20.
 */

var PszChip = cc.Sprite.extend({
    mChipNum : null,
    mNumSprite : null,
    ctor : function(){
        this._super();
        this.setAnchorPoint(cc.p(0.5, 0.5));

        this.mChipNum = 1;

        this.mNumSprite = new cc.Sprite();
        this.addChild(this.mNumSprite);

        this.setScale(0.8);
    },

    setChipNum : function(num){
        if (num >= 1 && num <= 10){
            this.mChipNum = num;
        }else{
            this.mChipNum = 1;
        }

        this.updateImg();
    },

    updateImg : function(){
        //背景
        if (this.mChipNum < 2){
            this.setSpriteFrame("psz_chip0.png");
        }else if (this.mChipNum < 4){
            this.setSpriteFrame("psz_chip1.png");
        }else if (this.mChipNum < 7){
            this.setSpriteFrame("psz_chip2.png");
        }else if (this.mChipNum < 9){
            this.setSpriteFrame("psz_chip3.png");
        }else if (this.mChipNum < 11){
            this.setSpriteFrame("psz_chip4.png");
        }

        //num
        this.mNumSprite.setSpriteFrame("psz_chip_num" + this.mChipNum + ".png");
        var size = this.getContentSize();
        this.mNumSprite.setPosition(cc.p(size.width / 2, size.height / 2));
    }
});